<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>第19章：原型对象 | MarkDown的使用</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../JavaScript/JavaScript_20.html" />
    
    
    <link rel="prev" href="../JavaScript/JavaScript_18.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="5.19"
        data-chapter-title="第19章：原型对象"
        data-filepath="JavaScript/JavaScript_19.md"
        data-basepath=".."
        data-revision="Sat Dec 01 2018 16:27:07 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="HTML/html_int.html">
            
                
                    <a href="../HTML/html_int.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML5简介
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="HTML/gitbook_use.html">
            
                
                    <a href="../HTML/gitbook_use.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        第0章：gitbook的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="HTML/lesson1.html">
            
                
                    <a href="../HTML/lesson1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        第1章：常用标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="HTML/lesson2.html">
            
                
                    <a href="../HTML/lesson2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第2章：列表与图片
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="HTML/lesson3.html">
            
                
                    <a href="../HTML/lesson3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        第3章：表格与表单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="HTML/lesson4.html">
            
                
                    <a href="../HTML/lesson4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        第4章：实体字符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="HTML/lesson5.html">
            
                
                    <a href="../HTML/lesson5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        第5章：多媒体和iframe
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="CSS/css_int.html">
            
                
                    <a href="../CSS/css_int.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS简介
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="CSS/css_1.html">
            
                
                    <a href="../CSS/css_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        第1章：引入css
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="CSS/css_2.html">
            
                
                    <a href="../CSS/css_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        第2章：选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="CSS/css_3.html">
            
                
                    <a href="../CSS/css_3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        第3章：属性选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="CSS/css_4.html">
            
                
                    <a href="../CSS/css_4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        第4章：伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="CSS/css_5.html">
            
                
                    <a href="../CSS/css_5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        第5章：盒子模型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="CSS/css_6.html">
            
                
                    <a href="../CSS/css_6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        第6章：伪对象选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="CSS/css_7.html">
            
                
                    <a href="../CSS/css_7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        第7章：font字体与边框
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="CSS/css_8.html">
            
                
                    <a href="../CSS/css_8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        第8章：行高
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="CSS/css_9.html">
            
                
                    <a href="../CSS/css_9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        第9章：文字与背景
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="CSS/css_10.html">
            
                
                    <a href="../CSS/css_10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        第10章：浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="CSS/css_11.html">
            
                
                    <a href="../CSS/css_11.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.11.</b>
                        
                        第11章：定位与渐变
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="CSS/css_12.html">
            
                
                    <a href="../CSS/css_12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.12.</b>
                        
                        第12章：css过渡与变形
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="CSS/css_13.html">
            
                
                    <a href="../CSS/css_13.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.13.</b>
                        
                        第13章：css动画
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="CSS/css_14.html">
            
                
                    <a href="../CSS/css_14.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.14.</b>
                        
                        第14章：css滤镜
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.15" data-path="CSS/css_15.html">
            
                
                    <a href="../CSS/css_15.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.15.</b>
                        
                        第15章：swiper与地图插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.16" data-path="CSS/css_16.html">
            
                
                    <a href="../CSS/css_16.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.16.</b>
                        
                        第16章：移动端rem布局
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.17" data-path="CSS/css_17.html">
            
                
                    <a href="../CSS/css_17.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.17.</b>
                        
                        第17章：伸缩盒子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="SASS/sass_int.html">
            
                
                    <a href="../SASS/sass_int.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        sass简介
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="SASS/sass_1.html">
            
                
                    <a href="../SASS/sass_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        第1章：sass安装与使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="SASS/sass_2.html">
            
                
                    <a href="../SASS/sass_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        第2章：sass语法入门
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="Bootstrap/Bootstrap_int.html">
            
                
                    <a href="../Bootstrap/Bootstrap_int.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Bootstrap简介
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="Bootstrap/Bootstrap_1.html">
            
                
                    <a href="../Bootstrap/Bootstrap_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        第1章：Bootstrap
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="JavaScript/JavaScript_int.html">
            
                
                    <a href="../JavaScript/JavaScript_int.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        JavaScript简介
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="JavaScript/JavaScript_1.html">
            
                
                    <a href="../JavaScript/JavaScript_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        第1章：JavaScript
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="JavaScript/JavaScript_2.html">
            
                
                    <a href="../JavaScript/JavaScript_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        第2章：变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="JavaScript/JavaScript_3.html">
            
                
                    <a href="../JavaScript/JavaScript_3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        第3章：Number
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="JavaScript/JavaScript_4.html">
            
                
                    <a href="../JavaScript/JavaScript_4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        第4章：数据类型判断
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="JavaScript/JavaScript_5.html">
            
                
                    <a href="../JavaScript/JavaScript_5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        第5章：运算符与字符串
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="JavaScript/JavaScript_6.html">
            
                
                    <a href="../JavaScript/JavaScript_6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        第6章：循环与流程控制
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="JavaScript/JavaScript_7.html">
            
                
                    <a href="../JavaScript/JavaScript_7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        第7章：函数与作用域
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="JavaScript/JavaScript_8.html">
            
                
                    <a href="../JavaScript/JavaScript_8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        第8章：String方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="JavaScript/JavaScript_9.html">
            
                
                    <a href="../JavaScript/JavaScript_9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        第9章：数组方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="JavaScript/JavaScript_10.html">
            
                
                    <a href="../JavaScript/JavaScript_10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        第10章：定时器与排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.11" data-path="JavaScript/JavaScript_11.html">
            
                
                    <a href="../JavaScript/JavaScript_11.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.11.</b>
                        
                        第11章：Date与Math
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.12" data-path="JavaScript/JavaScript_12.html">
            
                
                    <a href="../JavaScript/JavaScript_12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.12.</b>
                        
                        第12章：简单的DOM操作与垃圾回收
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.13" data-path="JavaScript/JavaScript_13.html">
            
                
                    <a href="../JavaScript/JavaScript_13.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.13.</b>
                        
                        第13章：DOM操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.14" data-path="JavaScript/JavaScript_14.html">
            
                
                    <a href="../JavaScript/JavaScript_14.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.14.</b>
                        
                        第14章：DOM修改样式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.15" data-path="JavaScript/JavaScript_15.html">
            
                
                    <a href="../JavaScript/JavaScript_15.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.15.</b>
                        
                        第15章：DOM常用标签属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.16" data-path="JavaScript/JavaScript_16.html">
            
                
                    <a href="../JavaScript/JavaScript_16.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.16.</b>
                        
                        第16章：鼠标坐标与拖拽
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.17" data-path="JavaScript/JavaScript_17.html">
            
                
                    <a href="../JavaScript/JavaScript_17.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.17.</b>
                        
                        第17章：滚动条
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.18" data-path="JavaScript/JavaScript_18.html">
            
                
                    <a href="../JavaScript/JavaScript_18.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.18.</b>
                        
                        第18章：事件冒泡与事件代理
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="5.19" data-path="JavaScript/JavaScript_19.html">
            
                
                    <a href="../JavaScript/JavaScript_19.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.19.</b>
                        
                        第19章：原型对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.20" data-path="JavaScript/JavaScript_20.html">
            
                
                    <a href="../JavaScript/JavaScript_20.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.20.</b>
                        
                        第20章：this
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.21" data-path="JavaScript/JavaScript_21.html">
            
                
                    <a href="../JavaScript/JavaScript_21.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.21.</b>
                        
                        第21章：Ajax
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >MarkDown的使用</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x5BF9;&#x8C61;&#x7684;&#x521B;&#x5EFA;&#x548C;&#x65B9;&#x6CD5;">&#x5BF9;&#x8C61;&#x7684;&#x521B;&#x5EFA;&#x548C;&#x65B9;&#x6CD5;</h1>
<pre><code>
    // &#x5B57;&#x9762;&#x91CF;&#x521B;&#x5EFA;
    var obj1 = {
        name : &quot;&#x5F20;&#x4E09;&quot;,
        age : 18
    }

    // &#x5DE5;&#x5382;&#x6A21;&#x5F0F;&#x7684;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;&#xFF08;&#x51FD;&#x6570;&#xFF09;
    function factory(name,age){
        /*var obj2 = {
            &quot;name&quot; : name,
            &quot;age&quot; : age
        }*/

        // ES6 &#x5C5E;&#x6027;&#x540D;&#x5B57;key&#x548C;value&#x76F8;&#x540C;&#x540D;&#x79F0;&#x65F6;&#x53EF;&#x4EE5;&#x5FFD;&#x7565;value
        return {
            name,
            age
        }
    }

    // &#x5DE5;&#x5382;&#x51FD;&#x6570;&#x7684;&#x7F3A;&#x70B9;&#xFF1A;&#x65E0;&#x6CD5;&#x901A;&#x8FC7;&#x65B9;&#x6CD5;&#x6765;&#x83B7;&#x53D6;&#x5BF9;&#x8C61;&#x7684;&#x6765;&#x6E90;
    var obj2 = factory(&quot;&#x674E;&#x56DB;&quot;,19);
    console.log(obj2 instanceof factory)

    // &#x901A;&#x8FC7;new&#x64CD;&#x4F5C;&#x7B26;(&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;) &#x53EF;&#x77E5;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x6765;&#x6E90;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;
    // &#x6784;&#x9020;&#x51FD;&#x6570;&#x4E00;&#x822C;&#x4EE5;&#x5927;&#x9A7C;&#x5CF0;&#x6CD5;&#x547D;&#x540D;
    var obj3 = new Object();
    console.log(obj3 instanceof Object)

    // Object.create(obj) &#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x4F5C;&#x7EE7;&#x627F;
    // obj&#x4E3A;null&#xFF0C;&#x521B;&#x5EFA;&#x51FA;&#x6765;&#x7684;&#x662F;&#x5B8C;&#x5168;&#x4E3A;&#x7A7A;&#x7684;&#x5BF9;&#x8C61;
    var obj4 = Object.create(Object.prototype);
    console.log(obj4 instanceof Object)


    /******************** &#x5BF9;&#x8C61;&#x5C5E;&#x6027; ********************/

    var obj5 = {
        name : &quot;&#x738B;&#x4E94;&quot;
    }
    obj5.age = 19;            // &#x5BF9;&#x8C61;.&#x5C5E;&#x6027; = &#x503C;
    obj5[&quot;sex&quot;] = &quot;man&quot;;    // &#x5BF9;&#x8C61;[&quot;&#x5C5E;&#x6027;&#x540D;&quot;]

    Object.defineProperty(obj5,&quot;tall&quot;,{
        value : 180,            // value&#x503C;
        // &#x53EF;&#x679A;&#x4E3E;,&#x9ED8;&#x8BA4;&#x4E3A;false,&#x4E3A;true&#x65F6;&#x624D;&#x80FD;&#x88AB;in&#x64CD;&#x4F5C;&#x7B26;&#x5339;&#x914D;&#x51FA;&#x6765;
        enumerable : true,        
        // &#x53EF;&#x6539;&#x5199;,&#x9ED8;&#x8BA4;&#x4E3A;true
        writable : true,
        // &#x53EF;&#x88AB;&#x64CD;&#x4F5C;&#x7B26;&#x63A7;&#x5236;(delete)&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;false
        configurable : true
    })


    // in &#x64CD;&#x4F5C;&#x7B26;  &#x5339;&#x914D;&#x53EF;&#x679A;&#x4E3E;&#x5C5E;&#x6027;
    for( var k in obj5 ){
        console.log( k , &quot;:&quot; , obj5[k] )
    }

    // ES6 for...of &#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x904D;&#x5386;&#x51FA;value
    var arr = [1,2,3];
    for( var v of arr ){
        console.log( v )
    }

    Object.defineProperty(obj5,&quot;weight&quot;,{
        /*value : 150,
        writable : true,*/
        enumerable : true,
        configurable : true,
        // &#x5C5E;&#x6027;&#x88AB;&#x8BBF;&#x95EE;&#x65F6;&#xFF0C;&#x6267;&#x884C;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;
        // &#x6BCF;&#x6B21;&#x8BBF;&#x95EE;&#x91CD;&#x65B0;&#x8BA1;&#x7B97;&#xFF0C;&#x53EF;&#x4EE5;&#x5199;&#x4E00;&#x4E9B;&#x52A8;&#x6001;&#x7684;&#x503C;&#x968F;&#x67D0;&#x79CD;&#x6761;&#x4EF6;&#x53D8;&#x5316;
        get : function(){
            //return this.tall * 1.1;
            return w;
        },
        // &#x5F53;&#x5C5E;&#x6027;&#x88AB;&#x8D4B;&#x503C;&#x64CD;&#x4F5C;&#x4E4B;&#x540E;&#xFF0C;&#x6267;&#x884C;&#x56DE;&#x8C03;
        set : function(newValue){
            console.log(&quot;set&quot;,newValue)
            // &#x9519;&#x8BEF;&#x793A;&#x8303;&#xFF1A;&#x4E0D;&#x8981;&#x5728;set&#x91CC;&#x9762;&#x8FDB;&#x884C;&#x5BF9;&#x540C;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x8D4B;&#x503C;&#x64CD;&#x4F5C;&#xFF0C;&#x4F1A;&#x5F15;&#x8D77;&#x6B7B;&#x5FAA;&#x73AF;
            // this.weight = newValue;
            w = newValue + this.tall;
            return w;
        }
    })
    var w;

    // Object.defineProperty &#x7684;&#x590D;&#x6570;&#x5F62;&#x5F0F;&#xFF0C;&#x540C;&#x65F6;&#x8BBE;&#x7F6E;&#x591A;&#x4E2A;&#x5C5E;&#x6027;
    Object.defineProperties(obj5,{
        &quot;job&quot; : {
            value : &quot;&#x626B;&#x5730;&quot;
        },
        &quot;hobby&quot; : {
            value : [&quot;flishing&quot;,&quot;swiming&quot;]
        }
    })
    console.log(obj5)
</code></pre><h1 id="&#x6784;&#x9020;&#x51FD;&#x6570;&#x548C;&#x539F;&#x578B;&#x5BF9;&#x8C61;">&#x6784;&#x9020;&#x51FD;&#x6570;&#x548C;&#x539F;&#x578B;&#x5BF9;&#x8C61;</h1>
<pre><code>
    // &#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;
    var obj1 = new Object();
    var num1 = new Number();
    var arr1 = new Array();

    /*****************************

     &#x51FD;&#x6570;&#x58F0;&#x660E;&#x540E;&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x6709;&#x4E00;&#x4E2A;&#x7A7A;&#x5BF9;&#x8C61;&#x4F5C;&#x4E3A;&#x51FD;&#x6570;&#x7684;&#x539F;&#x578B;(prototype) 
     &#x5B9E;&#x4F8B;&#x5316;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;_proto_&#x8BBF;&#x95EE;&#x8FD9;&#x4E9B;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x548C;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x4E0A;&#x7684;&#x65B9;&#x6CD5;

     &#x539F;&#x578B;&#x51FD;&#x6570;&#xFF1A;constructor&#x5C5E;&#x6027;&#x6307;&#x7684;&#x662F;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;_proto_&#x6307;&#x5411;&#x5F53;&#x524D;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x578B;(&#x4FD7;&#x79F0;&#x539F;&#x578B;&#x94FE;[[prototype]])

    *****************************/

    // &#x6784;&#x9020;&#x51FD;&#x6570;
    function Car(type){
        this.type = type;                // &#x5B9E;&#x4F8B;&#x5316;&#x540E;&#x7684;&#x5BF9;&#x8C61;&#x4E0A;&#x7684;&#x5C5E;&#x6027;
        // &#x6784;&#x9020;&#x51FD;&#x6570;&#x91CC;&#x7684;this&#x7684;&#x5C5E;&#x6027;&#x90FD;&#x662F;&#x653E;&#x5728;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x7684;&#xFF08;&#x72EC;&#x7ACB;&#xFF09;

        // &#x5148;&#x83B7;&#x53D6;&#x516C;&#x5171;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x518D;&#x53BB;&#x4FEE;&#x6539;
    }
    // Car.prototype &#x539F;&#x578B;&#x5BF9;&#x8C61;
    // Car.prototype &#x4E0A;&#x7684;&#x5C5E;&#x6027;&#x90FD;&#x662F;&#x5171;&#x4EAB;&#x7684;
    Car.prototype.run = function(){
        console.log(&quot;run&quot;)
    }
    var c1 = new Car(&quot;&#x8D27;&#x8F66;&quot;);
    var c2 = new Car(&quot;&#x8D2D;&#x7269;&#x8F66;&quot;);

    //console.log(c1 instanceof Car)    // true
    //console.log(c1.run == c2.run)        // true
</code></pre><h1 id="&#x5BF9;&#x8C61;&#x7684;&#x7EE7;&#x627F;">&#x5BF9;&#x8C61;&#x7684;&#x7EE7;&#x627F;</h1>
<pre><code>
    function Father(){
        this.name = &quot;&#x7236;&#x4EB2;&quot;;
        this.eat = function(){
            console.log(&quot;&#x5403;&#x996D;&quot;)
        }
    }
    function Son(){
        this.name = &quot;&#x513F;&#x5B50;&quot;;
        this.newSkill = &quot;ES6&quot;;
    }

    var f1 = new Father();
    // &#x5B50;&#x7C7B;&#x7684;&#x539F;&#x578B;&#x5C31;&#x662F;&#x7236;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;
    Son.prototype = f1;
    Son.prototype.constructor = Son;

    var s1 = new Son();
    console.log(f1,s1)


    // Object.create(&#x88AB;&#x7EE7;&#x627F;&#x7684;&#x5BF9;&#x8C61;)
    var s2 = Object.create(f1);
    console.log(s2)

    Father.prototype.skill = [&quot;html&quot;,&quot;css&quot;,&quot;js&quot;];

    // hasOwnProperty &#x5224;&#x65AD;&#x5BF9;&#x8C61;&#x4E0A;&#x7684;&#x5C5E;&#x6027;&#x662F;&#x4E0D;&#x662F;&#x5BF9;&#x8C61;&#x81EA;&#x5DF1;&#x62E5;&#x6709;&#x7684;&#x5C5E;&#x6027;
    console.log(&quot;hasOwnProperty&quot;,s1.hasOwnProperty(&quot;newSkill&quot;))
    // isPrototypeOf &#x5224;&#x65AD;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x548C;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x7684;&#x5173;&#x7CFB;
    console.log(&quot;isPrototypeOf&quot;,Son.prototype.isPrototypeOf(s1))
    // getPrototypeOf &#x8FD4;&#x56DE;&#x539F;&#x578B;&#x5BF9;&#x8C61;
    console.log(&quot;getPrototypeOf&quot;,Object.getPrototypeOf(s1) == Son.prototype)


    var obj5 = {
        name : &quot;five&quot;
    }
    // &#x963B;&#x6B62;&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x6269;&#x5C55;&#xFF08;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF09;
    Object.preventExtensions(obj5);
    obj5.age = 18;            // &#x4E0D;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;
    obj5.name = &quot;evif&quot;;        // &#x53EF;&#x4EE5;&#x4FEE;&#x6539;
    delete obj5.name;        // &#x53EF;&#x4EE5;&#x5220;&#x9664;
    console.log(obj5)


    var obj6 = {
        name : &quot;six&quot;
    }
    // &#x5BC6;&#x5C01;  &#x963B;&#x6B62;&#x62D3;&#x5C55;&#x5E76;&#x4E14;&#x7981;&#x6B62;&#x64CD;&#x4F5C;&#x7B26;&#xFF08;delete&#xFF09;
    Object.seal(obj6);
    obj6.name = &quot;xis&quot;;        // &#x53EF;&#x4EE5;&#x4FEE;&#x6539;
    delete obj6.name;        // &#x4E0D;&#x53EF;&#x4EE5;&#x5220;&#x9664;
    console.log(obj6)


    var obj7 = {
        name : &quot;seven&quot;
    }
    // &#x51BB;&#x7ED3;  &#x5728;seal()&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x7981;&#x6B62;&#x5BF9;&#x5C5E;&#x6027;&#x503C;&#x7684;&#x4FEE;&#x6539;
    Object.freeze(obj7);
    obj7.name = &quot;neves&quot;;    // &#x4E0D;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;
    console.log(obj7)


    var obj8 = {
        name : &quot;eight&quot;,
        age : 18
    }
    // &#x83B7;&#x53D6;&#x5C5E;&#x6027;&#x540D;&#xFF08;keys&#xFF09;
    console.log(Object.keys(obj8))
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../JavaScript/JavaScript_18.html" class="navigation navigation-prev " aria-label="Previous page: 第18章：事件冒泡与事件代理"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../JavaScript/JavaScript_20.html" class="navigation navigation-next " aria-label="Next page: 第20章：this"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
